<template>
    <div class="yContainerColumnCenter yMatch">
        <button id="btn_goMain" class="layui-btn" @click="click_into">进入应用({{timeLeft}}s)</button>
    </div>
</template>

<script>
    let $this, yFree, Global;
    let timer;

    export default {
        methods: {
            click_into: () => {
                if (timer != null) yFree.yStopRun(timer);
                yFree.yIntent(Global.IFinal.Page.main, null, 0);
                // yFree.yIPCSend('goMain');
            },
        },
        data() {
            return {
                timeLeft: 5,
            }
        },
        beforeCreate() {
            $this = this;
            yFree = $this.yFree;
            Global = $this.Global;
        },
        created() {
            timer = yFree.yRunOnLoop(1000, function () {
                if ($this.timeLeft <= 0) {
                    $this.click_into();
                    return;
                }
                $this.timeLeft--;
            }, true);
        },
    };
</script>

<style scoped>
    #btn_goMain {
        background: var(--YThemeColor);
        width: 300px;
        height: 100px;
        font-size: 30px;
    }
</style>
